package com.ks.sgms.servlet;
import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ks.sgms.dao.ScoreDao;
import com.ks.sgms.dao.StudentDao;
import com.ks.sgms.entity.Score;
import com.ks.sgms.entity.Student;

@WebServlet("/updateScore")
public class UpdateScoreServlet extends HttpServlet{
	@Override
	protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		req.setCharacterEncoding("UTF-8");
		Score score = new Score();
		score.student_id = req.getParameter("student_id_up");
		score.course_id = req.getParameter("course_id_up");
		score.score = Integer.parseInt(req.getParameter("score_up"));
		score.term =Integer.parseInt(req.getParameter("term_up"));
		
		boolean suc = new ScoreDao().updateScore(score);
		if(suc)
			req.getRequestDispatcher("score.jsp").forward(req, resp);	
		else
			req.getRequestDispatcher("score-update.jsp").forward(req, resp);	
	}
}
